
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @module kefu.message
* @author: Hjava
* @description: 新客服模块消息内包
* @since: 2018-07-22 19:56:11
*/
var kefu_constant_1 = __webpack_require__(/*! _kefu/kefu.constant */ "./src/core/kefu/kefu.constant.ts");
var bufferType_1 = __webpack_require__(/*! _util/bufferType */ "./src/core/utils/bufferType.ts");
var constant_1 = __webpack_require__(/*! _util/constant */ "./src/core/utils/constant.ts");
var protocol_1 = __webpack_require__(/*! _util/protocol */ "./src/core/utils/protocol.ts");
var KFMessage = {};
/**
 * 文本消息
 * @type {Function}
 */
KFMessage.KFTextMessage = protocol_1.default.Message.extend({
    __category: 'KF',
    __type: constant_1.MESSAGE_TYPE.MSG_TYPE_TEXT,
    uri: kefu_constant_1.default.KF.URI_KF_TEXT_INFO,
    init: function () {
        this.text = '';
        this.font_name = 'serif';
        this.font_size = 12;
        this.bold = false;
        this.cipher_type = constant_1.CIPHER_TYPE.NO_CIPHER;
    },
    marshall: function () {
        this.push(this.text, bufferType_1.default.STRING);
        this.push(this.font_name, bufferType_1.default.STRING);
        this.push(this.font_size, bufferType_1.default.INT);
        this.push(this.bold, bufferType_1.default.BOOLEAN);
        this.push(this.cipher_type, bufferType_1.default.SHORT);
    },
    unmarshall: function () {
        this.text = this.popString();
        this.font_name = this.popString();
        this.font_size = this.popInt();
        this.bold = this.popBool();
    }
});
/**
 * 图片消息
 * @type {Function}
 */
KFMessage.KFImageMessage = protocol_1.default.Message.extend({
    __category: 'KF',
    __type: constant_1.MESSAGE_TYPE.MSG_TYPE_IMAGE,
    uri: kefu_constant_1.default.KF.URI_KF_IMAGE_INFO,
    init: function () {
        this.thumbnail = '';
        this.normal = '';
        this.original = '';
        this.type = '';
        this.token = ''; //文件验证token
        this.originSize = 0;
        this.uploadImageType = 2;
    },
    marshall: function () {
        this.push(this.thumbnail, bufferType_1.default.STRING);
        this.push(this.normal, bufferType_1.default.STRING);
        this.push(this.original, bufferType_1.default.STRING);
        this.push(this.type, bufferType_1.default.STRING);
        this.push(this.token, bufferType_1.default.STRING);
        this.push(this.originSize, bufferType_1.default.INT);
        this.push(this.uploadImageType, bufferType_1.default.BYTE);
    },
    unmarshall: function () {
        this.thumbnail = this.popString();
        this.normal = this.popString();
        this.original = this.popString();
        this.type = this.popString();
        this.token = this.popString();
        this.originSize = this.popInt();
        this.uploadImageType = this.popByte();
    }
});
/**
 * 单图文消息
 * @type {Function}
 */
KFMessage.KFLinkMessage = protocol_1.default.Message.extend({
    __category: 'KF',
    __type: constant_1.MESSAGE_TYPE.MSG_TYPE_LINK,
    uri: kefu_constant_1.default.KF.URI_KF_LINK_INFO,
    init: function () {
        this.title = '';
        this.image = '';
        this.content = '';
        this.link = '';
    },
    marshall: function () {
        this.push(this.title, bufferType_1.default.STRING);
        this.push(this.image, bufferType_1.default.STRING);
        this.push(this.content, bufferType_1.default.STRING);
        this.push(this.link, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.title = this.popString();
        this.image = this.popString();
        this.content = this.popString();
        this.link = this.popString();
    }
});
/**
 * 多图文消息
 * @type {Function}
 */
KFMessage.KFMultiLinkMessage = protocol_1.default.Message.extend({
    __category: 'KF',
    __type: constant_1.MESSAGE_TYPE.MSG_TYPE_MULTI_LINK,
    uri: kefu_constant_1.default.KF.URI_KF_MULTI_LINK_INFO,
    init: function () {
        this.num = 0;
        this.content = '';
    },
    marshall: function () {
        this.push(this.num, bufferType_1.default.SHORT);
        this.push(this.content, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.num = this.popShort();
        this.content = this.popString();
    }
});
/**
 * 表情消息
 * @type {Function}
 */
KFMessage.KFEmotionMessage = protocol_1.default.Message.extend({
    __category: 'KF',
    __type: constant_1.MESSAGE_TYPE.MSG_TYPE_EMOTION,
    uri: kefu_constant_1.default.KF.URI_KF_EMOTION_INFO,
    init: function () {
        this.category = '';
        this.type = '';
        this.name = '';
    },
    marshall: function () {
        this.push(this.category, bufferType_1.default.STRING);
        this.push(this.type, bufferType_1.default.STRING);
        this.push(this.name, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.category = this.popString();
        this.type = this.popString();
        this.name = this.popString();
    }
});
/**
 * 事件消息
 * @type {Function}
 */
KFMessage.KFEventMessage = protocol_1.default.Message.extend({
    __category: 'KF',
    __type: constant_1.MESSAGE_TYPE.MSG_TYPE_EVENT,
    uri: kefu_constant_1.default.KF.URI_KF_EVENT_INFO,
    init: function () {
        this.type = '';
        this.text = '';
    },
    marshall: function () {
        this.push(this.type, bufferType_1.default.STRING);
        this.push(this.text, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.type = this.popString();
        this.text = this.popString();
    }
});
/**
 * 日历消息
 * @type {Function}
 */
KFMessage.KFCalendarMessage = protocol_1.default.Message.extend({
    __category: 'KF',
    __type: constant_1.MESSAGE_TYPE.MSG_TYPE_CALENDAR,
    uri: kefu_constant_1.default.KF.URI_KF_CALENDAR_INFO,
    init: function () {
        this.dtstart = 0;
        this.dtend = 0;
        this.summary = '';
        this.location = '';
        this.trigger = '';
        this.participant = '';
        this.remark = '';
        this.calendarID = '';
    },
    marshall: function () {
        this.push(this.dtstart, bufferType_1.default.LONG);
        this.push(this.dtend, bufferType_1.default.LONG);
        this.push(this.summary, bufferType_1.default.STRING);
        this.push(this.location, bufferType_1.default.STRING);
        this.push(this.trigger, bufferType_1.default.STRING);
        this.push(this.participant, bufferType_1.default.STRING);
        this.push(this.remark, bufferType_1.default.STRING);
        this.push(this.calendarID, bufferType_1.default.LONG);
    },
    unmarshall: function () {
        this.dtstart = this.popLong().value();
        this.dtend = this.popLong().value();
        this.summary = this.popString();
        this.location = this.popString();
        this.trigger = this.popString();
        this.participant = this.popString();
        this.remark = this.popString();
        this.calendarID = this.popLong().value();
    }
});
/**
 * 语音消息
 * @type {Function}
 */
KFMessage.KFAudioMessage = protocol_1.default.Message.extend({
    __category: 'KF',
    __type: constant_1.MESSAGE_TYPE.MSG_TYPE_VOICE,
    uri: kefu_constant_1.default.KF.URI_KF_AUDIO_INFO,
    init: function () {
        this.url = '';
        this.codec = 0;
        this.duration = 0;
        this.stamp = 0;
        this.token = ''; //文件验证token
    },
    marshall: function () {
        this.push(this.url, bufferType_1.default.STRING);
        this.push(this.codec, bufferType_1.default.SHORT);
        this.push(this.duration, bufferType_1.default.SHORT);
        this.push(this.stamp, bufferType_1.default.LONG);
        this.push(this.token, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.url = this.popString();
        this.codec = this.popShort();
        this.duration = this.popShort();
        this.stamp = this.popLong().value();
        this.token = this.popString();
    }
});
/**
 * 视频消息
 * @type {Function}
 */
KFMessage.KFVideoMessage = protocol_1.default.Message.extend({
    __category: 'KF',
    __type: constant_1.MESSAGE_TYPE.MSG_TYPE_VIDEO,
    uri: kefu_constant_1.default.KF.URI_KF_VIDEO_INFO,
    init: function () {
        this.videoUrl = '';
        this.screenshotUrl = 0;
        this.duration = 0;
        this.size = 0;
        this.width = 0;
        this.height = 0;
        this.timestamp = 0;
        this.token = ''; //文件验证token
    },
    marshall: function () {
        this.push(this.videoUrl, bufferType_1.default.STRING);
        this.push(this.screenshotUrl, bufferType_1.default.STRING);
        this.push(this.duration, bufferType_1.default.INT);
        this.push(this.size, bufferType_1.default.INT);
        this.push(this.width, bufferType_1.default.SHORT);
        this.push(this.height, bufferType_1.default.SHORT);
        this.push(this.timestamp, bufferType_1.default.LONG);
        this.push(this.token, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.videoUrl = this.popString();
        this.screenshotUrl = this.popString();
        this.duration = this.popInt();
        this.size = this.popInt();
        this.width = this.popShort();
        this.height = this.popShort();
        this.timestamp = this.popLong().value();
        this.token = this.popString();
    }
});
/**
 * 位置消息
 * @type {Function}
 */
KFMessage.KFGPSMessage = protocol_1.default.Message.extend({
    __category: 'KF',
    __type: constant_1.MESSAGE_TYPE.MSG_TYPE_GPS,
    uri: kefu_constant_1.default.KF.URI_KF_GPS_INFO,
    init: function () {
        this.latitude = 0;
        this.longitude = 0;
        this.name = '';
    },
    marshall: function () {
        this.push(this.latitude * 1000000, bufferType_1.default.INT);
        this.push(this.longitude * 1000000, bufferType_1.default.INT);
        this.push(this.name, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.latitude = this.popInt() / 1000000; //转换为实际数值
        this.longitude = this.popInt() / 1000000;
        this.name = this.popString();
    }
});
/**
 * VCard消息
 * @type {Function}
 */
KFMessage.KFVCardMessage = protocol_1.default.Message.extend({
    __category: 'KF',
    __type: constant_1.MESSAGE_TYPE.MSG_TYPE_VCARD,
    uri: kefu_constant_1.default.KF.URI_KF_VCARD_INFO,
    init: function () {
        this.uri = kefu_constant_1.default.KF.URI_KF_VCARD_INFO;
        this.uid = 0;
        this.name = '';
        this.account = '';
        this.type = 0;
        this.subtype = 0;
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.name, bufferType_1.default.STRING);
        this.push(this.account, bufferType_1.default.STRING);
        this.push(this.type, bufferType_1.default.SHORT);
        this.push(this.subtype, bufferType_1.default.SHORT);
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.name = this.popString();
        this.account = this.popString();
        this.type = this.popShort();
        this.subtype = this.popShort();
    }
});
/**
 * 文件消息
 * @type {Function}
 */
KFMessage.KFFileMessage = protocol_1.default.Message.extend({
    __category: 'KF',
    __type: constant_1.MESSAGE_TYPE.MSG_TYPE_FILE,
    uri: kefu_constant_1.default.KF.URI_KF_FILE_INFO,
    init: function () {
        this.id = '';
        this.url = '';
        this.name = '';
        this.format = '';
        this.size = 0;
        this.token = ''; //文件验证token
        // 文件大小高位
        this.lsize = 0;
    },
    marshall: function () {
        this.push(this.id, bufferType_1.default.STRING);
        this.push(this.url, bufferType_1.default.STRING);
        this.push(this.name, bufferType_1.default.STRING);
        this.push(this.format, bufferType_1.default.STRING);
        this.push(this.size, bufferType_1.default.INT);
        this.push(this.token, bufferType_1.default.STRING);
        this.push(this.lsize, bufferType_1.default.LONG);
    },
    unmarshall: function () {
        this.id = this.popString();
        this.url = this.popString();
        this.name = this.popString();
        this.format = this.popString();
        this.size = this.popInt();
        this.token = this.popString();
        this.lsize = this.popLong().value();
    }
});
KFMessage.KFNewEmotionMessage = protocol_1.default.Message.extend({
    __category: 'KF',
    __type: constant_1.MESSAGE_TYPE.MSG_TYPE_NEWEMOTION,
    uri: kefu_constant_1.default.KF.URI_KF_NEWEMOTION_INFO,
    init: function () {
        this.category = '';
        this.packageId = '';
        this.packageName = '';
        this.id = '';
        this.name = '';
        this.type = '';
        this.params = '';
    },
    marshall: function () {
        this.push(this.category, bufferType_1.default.STRING);
        this.push(this.packageId, bufferType_1.default.STRING);
        this.push(this.packageName, bufferType_1.default.STRING);
        this.push(this.id, bufferType_1.default.STRING);
        this.push(this.name, bufferType_1.default.STRING);
        this.push(this.type, bufferType_1.default.STRING);
        this.push(this.params, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.category = this.popString();
        this.packageId = this.popString();
        this.packageName = this.popString();
        this.id = this.popString();
        this.name = this.popString();
        this.type = this.popString();
        this.params = this.popString();
    }
});
KFMessage.KFQuoteMessage = protocol_1.default.Message.extend({
    __category: 'KF',
    __type: constant_1.MESSAGE_TYPE.MSG_TYPE_QUOTE,
    uri: kefu_constant_1.default.KF.URI_KF_QUOTE_INFO,
    init: function () {
        this.lastReply = '{}';
        this.quoted = '[]';
        this.searchText = '';
    },
    marshall: function () {
        this.push(this.lastReply, bufferType_1.default.STRING);
        this.push(this.quoted, bufferType_1.default.STRING);
        this.push(this.searchText, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.lastReply = this.popString();
        this.quoted = this.popString();
        this.searchText = this.popString();
        var lastReplyMessage = JSON.parse(this.lastReply);
        lastReplyMessage = {
            message: protocol_1.default.Response.fromBase64(lastReplyMessage.message),
            defaultText: lastReplyMessage.defaultText
        };
        this.lastReplyMessage = lastReplyMessage;
        var quoted = JSON.parse(this.quoted);
        this.quotedMessage = quoted.map(function (item) {
            return {
                message: protocol_1.default.Response.fromBase64(item.message),
                defaultText: item.defaultText
            };
        });
    }
});
exports.default = KFMessage;


//# sourceURL=webpack://MTDX/./src/core/kefu/kefu.message.ts?